<%--
  Created by IntelliJ IDEA.
  User: brss
  Date: 2017/8/8
  Time: 10:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>hyBolog登录</title>
    <!-- Bootstrap core CSS -->
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <!-- 本地CSS -->
    <link href="/css/adminLogin.css" rel="stylesheet">
</head>
<body>
<div class="container">

    <form class="form-signin" action="/loginCheck" id="loginForm">
        <h2 class="form-signin-heading">登录到hyBlog</h2>
        <label for="inputEmail" class="sr-only">Email address</label>
        <input type="email" name="email" id="inputEmail" class="form-control" placeholder="邮箱地址" required autofocus>
        <label for="inputPassword" class="sr-only">Password</label>
        <input type="password" name="password" id="inputPassword" class="form-control" placeholder="密码" required>
        <label for="checkCode" class="sr-only">验证码</label>
        <input type="text" name="checkCode" id="checkCode" class="form-control" placeholder="验证码" required>
        <img src="/portal/code" id="imgObj" class="pull-right"  alt="验证码">
        <div class="checkbox">
            <label>
                <input type="checkbox" value="remember-me"> Remember me
            </label>
        </div>
        <button class="btn btn-lg btn-primary btn-block" type="button" id="submitBtn">登录</button>
    </form>
</div> <!-- /container -->
<!-- jquery插件 -->
<script src="/jquery/jquery-3.2.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script>
    $("#submitBtn").click(function () {
        $.post("/loginCheck",$("#loginForm").serialize(), function(data){
            data = $.parseJSON(data);
            if (data.status==200){
                //alert("登录成功！");
                window.location.href="/admin/index";
            }else if (data.status==500){
                alert(data.msg);
            }else {
                alert("网络连接失败，没有收到服务器的响应！");
            }
        });
    });
    $("#imgObj").click(function (e) {
        $("#imgObj").attr('src',"/portal/code?r="+Math.random());
    });
</script>
</body>
</html>
